<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="fyicon.ico"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>飞扬报修系统</title>
<link href="__PUBLIC__/css/bootstrap.css" rel="stylesheet">
<link href="__PUBLIC__/css/style.css" rel="stylesheet">
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>

<body>
<input type="hidden" id="token" value="@#$_GET['token']#@">
 <div class="navbar navbar-fixed-bottom navbar-inverse" role="navigation">
       <div class="container">   
       	  <ul class="nav nav-pills">
           <li  class="active"><a href="__APP__/Home/StaffPage/add?token=@#$_GET['token']#@">一键接单</a></li>
            <li><a href="__APP__/Home/StaffPage/not?token=@#$_GET['token']#@">查看订单</a></li>
            <li><a href="__APP__/Home/AccountPage/logout">退出</a></li>
          </ul>
       </div>
    </div>
<div class="container1">
<div id="search">

  <div class="form-group">
    <div id="error_no_user" class="text-danger"> ！没有找到该用户</div>
     <div id="error_no_computer" class="text-danger"> ！该用户尚未添加电脑</div>
      <div id="error_phone" class="text-danger"> ！请输入正确号码</div>
    <label for="exampleInputEmail1">手机：</label>
    <input type="search" id="phone" class="form-control input-lg" placeholder="输入客户手机号码" autofocus>
  </div>
 
  <button id="submit" class="btn btn-primary btn-lg btn-block">提交</button>

</div>
</div>



<script type="text/javascript">
$(document).ready(function(){
    var token=$("#token").val();
$("#error_no_user").hide();
$("#error_no_computer").hide();
 $("#error_phone").hide();
  $("body").keydown(function() {
    if (event.keyCode == "13"){

    var phone=$("#phone").val();
       if(phone==""){
      $("#error_phone").show();
    }
    else{ $("#error_phone").hide();}
    
    if(!phone.match(/^0?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$/)){
      $("#error_phone").show();
    }
    else {$("#error_phone").hide();}
     if(phone.match(/^0?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$/) && phone!=""){
      //若均填写隐藏提示信息
      $("#error_phone").hide();
    $("#submit").text('查询中..');
    //alert(order_id);return;
    $.post("__APP__/Home/Staff/search_user?token="+token,{phone:phone},
      function(data){

        if(data.status!=2){
         if(data.error_code=='NO_USER'){
         $("#error_no_user").show();
          $("#submit").text('提交');
         }
         if(data.error_code=='NO_COMPUTER'){
          $("#error_no_computer").show();
            $("#submit").text('提交');
         }
        }else{
           $("#submit").text('查询成功跳转中');

         window.location.href="__APP__/Home/StaffPage/add_order/user_id/"+data.user_id+"?token="+token;
        }
      });//完成的订单号  
      }  
    }
  });
//用户点击确认完成订单
  $("#submit").on("click",function(){
   
    var phone=$("#phone").val();
       if(phone==""){
      $("#error_phone").show();
    }
    else{ $("#error_phone").hide();}
    
    if(!phone.match(/^0?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$/)){
      $("#error_phone").show();
    }
    else {$("#error_phone").hide();}
     if(phone.match(/^0?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$/) && phone!=""){
      //若均填写隐藏提示信息
      $("#error_phone").hide();
    $("#submit").text('查询中..');
    //alert(order_id);return;
    $.post("__APP__/Home/Staff/search_user?token="+token,{phone:phone},
      function(data){
 console.log(data)
        if(data.status!=2){
         if(data.error_code=='NO_USER'){
         $("#error_no_user").show();
          $("#submit").text('提交');
         }
         if(data.error_code=='NO_COMPUTER'){
          $("#error_no_computer").show();
            $("#submit").text('提交');
         }
        }else{
           $("#submit").text('查询成功跳转中');

         window.location.href="__APP__/Home/StaffPage/add_order/user_id/"+data.user_id+"?token="+token;
        }
      });//完成的订单号  
      }  
  });
});
</script>
</body>
</html>
